package analyzer;

import java.util.regex.Matcher;
import java.util.regex.Pattern;


import Data.DictionaryData;
import Data.inputArticle;
import Data.wrongWordsData;



public class Analyzer {
	
	public boolean modifier(String vocab) {
		vocab = vocab.toUpperCase();
		boolean returnValue=false;
		DictionaryData dictionary_data = new DictionaryData();
		returnValue = dictionary_data.getWordList().contains(vocab);
		return returnValue;
	}
	
	public void handleInputArticle(String article){
		Matcher m = Pattern.compile("([a-zA-z])+").matcher(article);
		while (m.find()) {
			inputArticle.addword(m.group());
		}
	}
	public char grading(){
		double wordWordnumber = wrongWordsData.getWrongWordNumber();
		double inputWord =inputArticle.getInputWordNumber();
		double mark = (inputWord - wordWordnumber)/inputWord;
		return return_grading(mark);
	}
	
	public char return_grading(double mark){
		char grade;
		if (mark > 0.8)
			grade ='A';
		else if (mark > 0.7)
			grade ='B';
		else if (mark > 0.6)
			grade ='C';
		else if (mark > 0.5)
			grade ='D';
		else if (mark > 0.4)
			grade ='E';
		else
			grade ='F';
		return grade;
	}

}
